package com.hangkong.controller;

import com.hangkong.model.BackResult;
import com.hangkong.model.User;
import com.hangkong.model.tuser;
import com.hangkong.service.UserService;
import com.hangkong.service.UserService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by Zhangxq on 2016/7/15.
 */

@Controller
@RequestMapping("/user")
public class UserController {
//
    private Logger log = Logger.getLogger(UserController.class);
    @Resource
    private UserService userService;

    @RequestMapping("/login")
    public String login(HttpServletRequest request,Model model){
        log.info("登录方法");
        String  userName = request.getParameter("userName");
        String  userPwd = request.getParameter("userPwd");
        String error="登录失败";
        model.addAttribute("error",error);
        tuser userList = userService.login(userName,userPwd);

        if (userList!=null){

            return "main";

        }else{
            return "error";
        }

    }


}
